{include file='header'/}
<title>添加内容</title>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layuimini-form" action="javascript:" onsubmit="return dosub(this)" onkeydown="if(event.keyCode==13){return false;}" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label required">类型</label>
                <div class="layui-input-block">
                    <label>
                        <select name="type_content" lay-verify="required" lay-reqtext="请选择类型">
                            <option value="1">政策原文</option>
                            <option value="2">实施细则</option>
                        </select>
                    </label>
                </div>
            </div>
            <input type="hidden" name="type_md" id="type_md" value="2">
            <input type="hidden" name="type_id" id="type_id" value="{$type_id}">
            <div class="layui-form-item">
                <label class="layui-form-label required">标题</label>
                <div class="layui-input-block">
                    <label for="title">
                        <input type="text" id="title" name="title" value="" lay-verify="required" autocomplete="off"
                               class="layui-input" lay-reqtext="标题不能为空">
                    </label>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">时间</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="range_time" name="range_time" placeholder="开始时间 至 结束时间">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">点击量</label>
                    <div class="layui-input-inline">
                        <label for="click">
                            <input type="number" id="click" name="click" value="{$click}" autocomplete="off"
                                   class="layui-input">
                        </label>
                        <tip>默认随机100以内</tip>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">权重</label>
                    <div class="layui-input-inline">
                        <label for="weight">
                            <input type="number" id="weight" name="weight" value="999" autocomplete="off"
                                   class="layui-input">
                        </label>
                        <tip>越小排序越靠前</tip>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">来源</label>
                    <div class="layui-input-inline">
                        <label for="nickname">
                            <input type="text" id="nickname" name="nickname"
                                   value=""
                                   autocomplete="off" class="layui-input">
                        </label>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">PDF文件</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline" style="width: 50%">
                        <input type="text" name="file_url" id="file_url" value=""
                               onmouseover="hui_img_preview('image-select-input',this.value)"
                               onmouseout="layer.closeAll();" id="image-select-input" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width: 120px">
                        <button type="button" class="layui-btn" id="pdf_file_url">
                        <i class="layui-icon">&#xe67c;</i>选择PDF文件
                        </button>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">内容</label>
                {if($editor eq 1)}
                <div class="layui-input-block" id="contentEditorHtml" style="z-index: 0">
                    {php}echo lib\Form::editor('content',$val='', 'width:100%;height:400px');{/php}
                </div>
                {else}
                <div class="layui-input-block" id="contentEditorMD">
                    {php}echo lib\Form::editorMd('content',$val='');{/php}
                </div>
                {/if}
            </div>

            <div class="layui-form-item layui-hide">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-block">
                    <input type="hidden" name="editor" value="{$editor}">
                    <input type="hidden" name="status" value="1">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" onclick="set_status(1)">立即提交
                    </button>
                    <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="set_status(0)"> 保存草稿
                    </button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{include file='footer'/}
<script>
  layui.use(['form', 'jquery','laydate','upload'], function () {
    let form = layui.form, laydate = layui.laydate, $ = layui.jquery, upload = layui.upload;
    form.render();

    upload.render({
        elem: '#pdf_file_url'
        , url: "{:__url('upload/index',['save_path'=>'PDF'])}"
        ,accept: 'file'
        ,exts: 'pdf'
        , done: function (res) {
            if (res.code === 1) {
                $("#file_url").val(res.url);
            }
        }
    })
    laydate.render({
      elem: '#range_time'
      ,type: 'date'
      ,range: '至'
      ,format: 'yyyy-M-d'
    });
    window.dosub = function (obj) {
      HuiDoSub($(obj).serialize(), "{:__url('content.Article/add')}");
    }
  })
  ;
</script>

</body>
</html>
